package com.zeroxml.cms.service.impl;

import com.zeroxml.cms.service.ILinkService;
import com.zeroxml.cms.bo.Link;
import com.zeroxml.cms.dao.ILinkDAO;
import com.wyvoid.core.persistent.hibernate.HibernatePage;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

/**
 * User: cjp
 * Date: 2007-9-22
 * Time: 11:59:01
 */
public class LinkService implements ILinkService {
    private ILinkDAO linkDAO;


    public void setLinkDAO(ILinkDAO linkDAO) {
        this.linkDAO = linkDAO;
    }

    public List<Link> getLinks(long catalogId) {
        return linkDAO.getLinks(catalogId);
    }

    @Transactional
    public void addLink(Link link) {
        linkDAO.create(link);
    }

    @Transactional
    public void updateLink(Link link) {
        linkDAO.update(link);
    }

    public Link getLink(long id) {
        return linkDAO.getById(id);
    }

    public HibernatePage<Link> getAllLinks(int curPage,int pageSize) {
        return linkDAO.getAllLinks(curPage,pageSize);
    }

    @Transactional
    public void deleteLink(long linkId) {
        linkDAO.deleteById(linkId);
    }

    public List<Link> getIndexLinks(int i) {
        return linkDAO.getIndexLinks(i);
    }
}
